package sostats.core.query;

import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Joiner;

public class GroupBy extends Clause{
	private final List<String> columns;
	public GroupBy(SqlContext context) {
		super(context,"GROUP BY");
		columns= new ArrayList<String>();
	}
	public GroupBy column(String column){
		columns.add(column);
		return this;
	}
	public Having having(){
		endClause();
		return new Having(super.context);
	}
	public void endClause(){
		super.context.append(Joiner.on(',').join(columns));
	}
}
